<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vue v-on</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@3"></script>
  </head>
  <body>
    <div id="app">
      <h1>Vue实例</h1>
      <hr />
      <!-- .enter是键盘修饰符，相当于按下回车键 -->
      <input type="text" @keyup.enter="keyUpHandle" />
      <!-- 当绑定事件的时候，如果不传参数那么默认是event对象 -->
      <button v-on:click="clickHandle">按钮</button>
      <button @click="clickHandle(22)">按钮2</button>
    </div>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            message: "Hello Vue!",
          };
        },
        // 在vue中所有的时间都需要写在methods属性中
        methods: {
          clickHandle(e) {
            console.log(e);
          },
          keyUpHandle(e) {
            console.log(e);
          },
        },
      });
      console.log(app);
      app.mount("#app");
    </script>
  </body>
</html>
